import React, { FC, useRef } from "react"

const UseRefDemo: FC = () => {
  const inputRef = useRef<HTMLInputElement>(null)
  const select = () => {
    const input = inputRef.current
    input && input.select()
  }

  return (
    <div>
      <input ref={inputRef} type="text" defaultValue="defaultValue" />
      <button onClick={select}>click</button>
    </div>
  )
}

export default UseRefDemo
